function scan=scanread(path,filename,scann)

%READSCAN  Read a SPEC scan and the corresponding EDF images. 
%(from Simo's readscan.m but without saving anything and taking a directory...)
% edf images in 'edfprefix' folder in 'path'

%INPUT: path = path to the Specfile 'filename', should contain 'edf/'
%              folder 
%       filename = filename of SPEC file
%       scann = scannumber or scannumbers
%OUTPUT: structure containing: -'dets' deector names (names of columns in SPEC file)
%                              -'A' read edf-files in array format 
%                              -'s' SPEC file ???
%                              -'motors'

edfprefix='edf/';
edfpostfix='.edf';
[s,dets,motors]=specread5([path filename],scann);%specread5([dirprefix filename],scann);
A=zeros(size(s,1),256,256);
for ii=1:size(s,1)
	edfname = [path edfprefix filename '_' sprintf('%04d',dets.ccdno(ii)+1) edfpostfix];
    A(ii,:,:)=readedf(edfname);
end

scan=dets;
scan.A=A;
scan.s=s;
scan.motors=motors;
try scan.B=B; catch scan.B=0; end 